//
//  AENewsLikeRequest.m
//  AESOLAR_IOS
//
//  Created by Bin Tang on 2024/10/27.
//  Copyright © 2024 Mr.Wang. All rights reserved.
//

#import "AENewsLikeRequest.h"
#import "AE_Solar-Swift.h"

@interface AENewsLikeRequest ()

/// 新闻id
@property (nonatomic, assign) NSInteger newsId;
@property (nonatomic, assign) NSInteger like;

/// 评论id
@property (nonatomic, assign) NSInteger commentId;
@end

@implementation AENewsLikeRequest

/// 点赞或取消
/// - Parameters:
///   - newsId: newsId description
///   - like: 1 点赞；0 取消
- (instancetype)initWithNewsId:(NSInteger)newsId like:(NSInteger)like {
    if (self = [super init]) {
        self.newsId = newsId;
        self.like = like;
    }
    return self;
}

- (instancetype)initWithCommentId:(NSInteger)commentId like:(NSInteger)like {
    if (self = [super init]) {
        self.commentId = commentId;
        self.like = like;
    }
    return self;
}



- (NSString *)requestUrl {
    return kAPP_NEWS_INFO_LIKE;
}

- (TYZRequestMethod)requestMethod {
    return TYZRequestMethodPOST;
}

- (id)requestArgument {
    NSDictionary *params = @{
        @"newsId":@(self.newsId),
        @"like": @(self.like)
    };
    if (self.commentId > 0) {
        params = @{
            @"commentId":@(self.commentId),
            @"like": @(self.like)
        };
    }
    NSString *json = [params yy_modelToJSONString];
    NSString *aesStr = [AESCrypt AES128Encrypt:json key:[AEUserCommonInfo getAesKey]];
    return @{@"requestData": aesStr};
}

@end
